//package Code;
//
//import java.sql.DriverManager;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.sql.SQLException;
// 
//import DatabaseCommands.DatabaseInfo;
//import DatabaseCommands.DatabaseManager;
//import DatabaseCommands.SWQuery;
//
//import com.jcraft.jsch.JSch;
//import com.jcraft.jsch.Session;
//import java.sql.Connection;
// 
// 
//public class MySqlConnOverSSH {
// 
//    /**
//     * Java Program to connect to remote database through SSH using port forwarding
//     * @author Pankaj@JournalDev
//     * @throws SQLException
//     */
//    public static void main(String[] args) throws SQLException {
//    	
// 
//        int lport=22;
//        String rhost="sloop.cs.ship.edu";
//        String host="sloop.cs.ship.edu";
//        int rport=22;
//        String user="es7976";
//        String password="ambralfb";
//        String dbuserName = "csc371-10";
//        String dbpassword = "Password10";
//        String url = "jdbc:mysql://localhost:"+lport+"/csc371-10";
////        String url = "jdbc:mysql://localhost:5656/csc371-10";
//        String driverName="com.mysql.jdbc.Driver";
//        Connection conn = null;
//        Session session= null;
//        try{
//            //Set StrictHostKeyChecking property to no to avoid UnknownHostKey issue
//            java.util.Properties config = new java.util.Properties();
//            config.put("StrictHostKeyChecking", "no");
//            JSch jsch = new JSch();
//            session=jsch.getSession(user, host, 22);
//            session.setPassword(password);
//            session.setConfig(config);
//            session.connect();
//            System.out.println("Connected");
//            int assinged_port=session.setPortForwardingL(lport, rhost, rport);
//            System.out.println("localhost:"+assinged_port+" -> "+rhost+":"+rport);
//            System.out.println("Port Forwarded");
//             
//            
//            
////            DatabaseManager DManager=DatabaseManager.getInstance();
////    		System.out.println("1");
////    		DManager.activateJDBC();
////    		System.out.println("2");
//////    		DatabaseInfo DInfo=new DatabaseInfo(SWQuery.DB_LOCATION, SWQuery.LOGIN_NAME, SWQuery.PASSWORD);
////    		DatabaseInfo DInfo=new DatabaseInfo("jdbc:mysql://localhost:3306/csc371-10","csc371-10","Password10");
////    		System.out.println("3");
////    		
////    		Connection DConnection=DInfo.makeConnection();
////    		System.out.println("4");
////    		
////    		ResultSet Results=DConnection.createStatement().executeQuery("Select * From Book");
////    		System.out.println("5");
////    		
////    		while(Results.next()){
////    			System.out.println(Results.getString(2));
////    		}
//            
//            
//            
////            mysql database connectivity
//            Class.forName(driverName).newInstance();
//            System.out.println("1");
////            conn = DriverManager.getConnection (url, dbuserName, dbpassword);
//            conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/csc371-10", dbuserName, dbpassword);
////            conn = DriverManager.getConnection ("jdbc:mysql://db.cs.ship.edu:3306/csc371-10?user=csc371-10&password=Password10");
//            System.out.println ("Database connection established");
//            System.out.println("DONE");
//        }catch(Exception e){
//            e.printStackTrace();
//        }finally{
//            if(conn != null && !conn.isClosed()){
//                System.out.println("Closing Database Connection");
//                conn.close();
//            }
//            if(session !=null && session.isConnected()){
//                System.out.println("Closing SSH Connection");
//                session.disconnect();
//            }
//        }
//    }
// 
//}